<%= form_for(@cultural_heritage_care_and_maintenance,  :html=>{:onsubmit => "return validate(this);" }) do |f| %>
  <% if @cultural_heritage_care_and_maintenance.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@cultural_heritage_care_and_maintenance.errors.count, "error") %> prohibited this cultural_heritage_care_and_maintenance from being saved:</h2>

      <ul>
      <% @cultural_heritage_care_and_maintenance.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
 

  <%#*<div class="field">%>
    <%#*<label>Tipo de Persona:</label><br />%>
    <%#= select_tag "person_type", '<option value = "0">Natural</option><option value = "1">Jurídica</option>'.html_safe, :include_blank=>"Seleccione", :class => 'combobox' %>

  <%#*</div>%>

  <div class="field">
    <%= f.label :security_person, "Encargado" %><br />
    <%= f.select :security_person, @security_people.collect { |t| [t.name + " " + t.lastname,t.id]}, {:include_blank=>"Seleccione"}, {:class => 'combobox'} %>
  </div>


  <div class="field">
    <%= f.label :cultural_heritage, "Patrimonio Cultural" %><br />
    <%= f.select :cultural_heritage, @cultural_heritages.collect { |t| [t.name,t.id]}, {:include_blank=>"Seleccione"}, {:class => 'combobox'} %>
  </div>

  <div class="field">
    <%= f.label :description, "Descripción" %><br />
    <%= f.text_area :description %>
  </div>
  <div class="field">
    <label>Fecha Inicio</label><br />
    <%= f.datepicker 'start_date'%>
  </div>
  <div class="field">
    <label>Fecha Fin</label><br />
    <%= f.datepicker 'end_date'%>
  </div>
  <div class="field">
    <%= f.label :cultural_institution, 'Institución Cultural' %><br />
    <%= f.select :cultural_institution, @cultural_institutions.collect { |t| [t.name,t.id]}, {:include_blank=>"Seleccione"},{:class => 'combobox'} %>
  </div>
  <div class="field">
    <%= f.label :care_and_maintenance_type, 'Tipo' %><br />    
    <%#= f.text_field :care_and_maintenance_type %><br />
    <%= f.select :care_and_maintenance_type, @cultural_care_and_maintenance_types.collect { |t| [t.name,t.id]}, {:include_blank=>"Seleccione"},{:class => 'combobox'} %>
  </div>

 <div class="field">
    <%= f.label :mayor, 'Magnitud:' %><br />
    <%=@lalala%>
    <%= f.select(:mayor, options_for_select([["Mayor",1],["Menor",0]], :selected=>@lalala),{:include_blank=>"Seleccione"}, {:onchange => "toggle(this);"}) %>
    <%#=  select_tag "cultural_heritage_care_and_maintenance_mayor",  options_for_select([["Mayor",0],["Menor",1]]) %>

    <%#= f.text_field :care_and_maintenance_type %>    
    <%#= select_tag "care_and_maintenance_magnitud", '<option value = "0">Mayor</option> <option value = "1">Menor</option>'.html_safe, :include_blank=>"Seleccione", :onchange => 'toggle(this);' %>
  </div>

<%if @cultural_heritage_care_and_maintenance.mayor == 0
    @none = "none"
  else
    @none = ""
  end
%>

<div id="sel_supervisor" class="field" style="display: <%=@none%>">
    <%= f.label :supervisor, 'Supervisores' %><br />
    <%= f.select :supervisor, @care_and_maintenance_supervisors.collect { |t| [t.name + " " + t.lastname,t.id]}, {:include_blank=>"Seleccione"},{:class => 'combobox'} %>
  </div>

 <div class="actions">
    <%= f.submit "Enviar" %>
  </div>
<% end %>

<script type="text/javascript">
  //Mostrar las opciones de eliminar foto
        /*
        function toggle() {
          elems = $(".delete_photo");
          for(i=0; i < elems.length; i++)
            elems[i].style.display = (elems[i].style.display != 'none' ? 'none' : '' );
        }*/


        function toggle(oSelect) {
          var selectedValue = oSelect.options[ oSelect.selectedIndex ].value;

          var el = document.getElementById("sel_supervisor");

          if (selectedValue == 1){
            //alert(0);
            el.style.display = '';
          }
          else{
            //alert(1);
            el.style.display = 'none';
          }
        }
        
</script>
